1. Technical Field
This disclosure generally relates to debuggers, and more specifically relates to stepping in debuggers.
2. Background Art
Computer systems have evolved into extremely sophisticated devices, and may be found in many different settings. Computer systems typically include a combination of hardware, such as semiconductors and circuit boards, and software, also known as computer programs. As advances in semiconductor processing and computer architecture push the performance of the computer hardware higher, more sophisticated computer software has evolved to take advantage of the higher performance of the hardware, resulting in computer systems today that are much more powerful than just a few years ago.
As the sophistication and complexity of computer software increase, the more difficult the software is to debug. Debugging is the process of finding problems, or “bugs”, during the development of a computer program. Most modern programming environments include a debugger that provides tools for testing and debugging a computer program. Dbx is a popular Unix-based source-level debugger. One useful feature of dbx is the ability to step through programs one source line at a time, or one machine instruction at a time. An instruction step steps one machine instruction at a time. A line step steps one source code line at a time. However, the definition of “line” within a dbx debugger can vary. For example, in some dbx debuggers, a line is defined to be a line in the source code. In others a line is a statement, and there may be multiple statements in a single line of source code. Thus, a line like a=1; b=2; results in two steps when statement level stepping is done. This can be particularly annoying when macros with multiple statements are encountered. In C and C++, a macro is a single line. For debuggers that do statement stepping when line stepping is specified, the user will have to step once for each statement in the macro. For debuggers that do true line stepping, the user will have to step only once to execute the macro.
At other times statement stepping may be desirable. Consider a loop like: while (some condition) foo( ); The way compilers expand while loops, the first instructions generated are actually not in the loop. A breakpoint used to implement a line step must be set on the very first instruction of the line. Because of this, when line stepping with a step over type of operation, the debugger will stop on this line once. Another step will complete all iterations of the loop and stop on the next line. Statement level stepping would stop on the call to foo( ) each time through the loop when a step over operation was done. Many users would find this preferable.
Known dbx debuggers implement line stepping as either a line step or a statement step, and always use this implementation whenever line stepping is specified. A programmer is thus stuck with the implementation of line stepping in each particular dbx debugger. Without a way for a programmer to specify desired line stepping modes, the user will be unable to vary the function of the debugger according to his or her needs.